﻿<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<!--[if lt IE 9]>
<script type="text/javascript" src="__PUBLIC__/lib/html5shiv.js"></script>
<script type="text/javascript" src="__PUBLIC__/lib/respond.min.js"></script>
<![endif]-->
<link rel="stylesheet" type="text/css" href="__PUBLIC__/static/h-ui/css/H-ui.min.css" />
<link rel="stylesheet" type="text/css" href="__PUBLIC__/static/h-ui.admin/css/H-ui.admin.css" />
<link rel="stylesheet" type="text/css" href="__PUBLIC__/lib/Hui-iconfont/1.0.8/iconfont.css" />
<link rel="stylesheet" type="text/css" href="__PUBLIC__/static/h-ui.admin/skin/default/skin.css" id="skin" />
<link rel="stylesheet" type="text/css" href="__PUBLIC__/static/h-ui.admin/css/style.css" />
<!--[if IE 6]>
<script type="text/javascript" src="__PUBLIC__/lib/DD_belatedPNG_0.0.8a-min.js" ></script>
<script>DD_belatedPNG.fix('*');</script>
<![endif]-->
    <style>
        .select{
            width: 10%;
        }
    </style>

<title>接单信息管理</title>
</head>
<body>
<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 接单信息管理 <span class="c-gray en">&gt;</span> 接单信息列表 <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a></nav>
<div class="page-container">
    <div class="text-c"> 接单日期范围：
        <input type="text" onfocus="WdatePicker({ maxDate:'#F{$dp.$D(\'datemax\')||\'%y-%M-%d\'}' })" id="datemin" class="input-text Wdate" style="width:120px;">
        -
        <input type="text" onfocus="WdatePicker({ minDate:'#F{$dp.$D(\'datemin\')}',maxDate:'%y-%M-%d' })" id="datemax" class="input-text Wdate" style="width:120px;">
        <!--<input type="text" class="input-text" style="width:250px" placeholder="接单号" id="" name="">-->
        <button type="button" class="btn btn-success" id="search" name=""><i class="Hui-iconfont">&#xe665;</i> 查询</button>
    </div>


    <div class="cl pd-5 bg-1 bk-gray mt-20">
        <span class="l">
            <a href="javascript:;" onclick="datadel()" class="btn btn-danger radius">
                <i class="Hui-iconfont">&#xe6e2;</i> 批量删除
            </a>
            <a href="javascript:;" onclick="member_add('新增接单','/order/add','','510')" class="btn btn-primary radius">
                <i class="Hui-iconfont">&#xe600;</i> 新增接单
            </a>
        </span>

        <span class="r">共有数据：<strong><!--{$ordercount}--></strong> 条</span>
    </div>


	<div class="mt-20">
        <div style="height: 40px;margin-left: 5px">
            <button onclick="javascript:method1('ta')"   class="btn btn-success radius" id="save" name=""><i class="icon Hui-iconfont">&#xe644;</i> EXcel导出</button>
        </div>

	<table class="table table-border table-bordered table-hover table-bg table-sort" id="ta">
		<thead>
			<tr class="text-c">
				<th width="25"><input type="checkbox" name="" value=""></th>
				<th width="70">接单日期</th>
				<th width="70">客户</th>
				<th width="200">接单号</th>
                <th width="75">接单QQ</th>
				<th width="60">设计师</th>
				<th width="15">面数</th>
				<th width="50">价格(￥)</th>
                <th width="130">支付宝账号</th>
				<th width="15">接单状态</th>
                <th width="70">修改后日期</th>
                <th width="70">供应商</th>
                <th width="70">收件人</th>
                <th width="75">收件人电话</th>
                <th width="110">收件人地址</th>
                <th width="15">结款</th>
				<th width="50">操作</th>
			</tr>
		</thead>
		<tbody>
        <foreach name="orderinfo" item="val">
			<tr class="text-c">
				<td><input type="checkbox" value="<!--{$val['id']}-->" class="id" name="checkbox"></td>
				<td><!--{$val['ord_date']}--></td>
				<td><!--{$val['customer']}--></td>
				<td><!--{$val['ord_num']}--></td>
				<td><!--{$val['qq']}--></td>
				<td><!--{$val['designer']}--></td>
				<td><!--{$val['face_count']}--></td>
				<td><!--{$val['price']}--></td>
                <td><!--{$val['alipay']}--></td>
                <td><!--{$val['state']}--></td>
                <td><!--{$val['edit_date']}--></td>
                <td><!--{$val['supplier']}--></td>
                <td><!--{$val['consignee']}--></td>
                <td><!--{$val['cons_tel']}--></td>
                <td><!--{$val['address']}--></td>
				<td><!--{$val['payment']}--></td>
				<td class="td-manage">
                    <if condition="$val['payment']==已结款">
                        <s><a title="编辑" href="javascript:void(0);" class="ml-5" style="text-decoration:none"><i class="Hui-iconfont">&#xe6df;</i></a></s>
                        <s><a title="删除" href="javascript:;"  class="ml-5" style="text-decoration:none"><i class="Hui-iconfont">&#xe6e2;</i></a></s>
                        <else/>
                        <a title="编辑" href="javascript:void(0);" onclick="member_edit('编辑','/order/edit/id/',<!--{$val['id']}-->,'','510')" class="ml-5" style="text-decoration:none"><i class="Hui-iconfont">&#xe6df;</i></a>
                        <a title="删除" href="javascript:;" onclick="member_del(this,<!--{$val['id']}-->)" class="ml-5" style="text-decoration:none"><i class="Hui-iconfont">&#xe6e2;</i></a>
                    </if>
                </td>
			</tr>
        </foreach>
		</tbody>
	</table>
	</div>
</div>
<!--_footer 作为公共模版分离出去-->
<script type="text/javascript" src="__PUBLIC__/lib/jquery/1.9.1/jquery.min.js"></script> 
<script type="text/javascript" src="__PUBLIC__/lib/layer/2.4/layer.js"></script>
<script type="text/javascript" src="__PUBLIC__/static/h-ui/js/H-ui.min.js"></script> 
<script type="text/javascript" src="__PUBLIC__/static/h-ui.admin/js/H-ui.admin.js"></script> <!--/_footer 作为公共模版分离出去-->

<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="__PUBLIC__/lib/My97DatePicker/4.8/WdatePicker.js"></script> 
<script type="text/javascript" src="__PUBLIC__/lib/datatables/1.10.0/jquery.dataTables.min.js"></script> 
<script type="text/javascript" src="__PUBLIC__/lib/laypage/1.2/laypage.js"></script>
<script type="text/javascript">

    function method1(tableid) {
        var curTbl = document.getElementById(tableid);
        var oXL = new ActiveXObject("Excel.Application");
        var oWB = oXL.Workbooks.Add();
        var oSheet = oWB.ActiveSheet;
        var sel = document.body.createTextRange();
        sel.moveToElementText(curTbl);
        sel.select();
        sel.execCommand("Copy");
        oSheet.Paste();
        oXL.Visible = true;
    }

	var table =$('.table-sort').dataTable({
		"aaSorting": [[15,"dasc"],[ 1,"desc"]],//默认第几个排序
		"bStateSave": false,//状态保存
		"aoColumnDefs": [
		  //{"bVisible": false, "aTargets": [ 3 ]} //控制列的隐藏显示
		  {"orderable":false,"aTargets":[0,1,6,9,12,13,14,15,16]}// 制定列不参与排序
		],
        initComplete: function () {
            var api = this.api();
            api.columns().indexes().flatten().each( function ( i ) {
                if(i==9||i==5 ||i==2 || i==15){
                    var column = api.column( i );
                    var select = $('<select><option value="">筛选</option></select>')
                            .appendTo($(column.header()))
                            .on( 'change', function () {
                                var val = $(this).val();
                                column
                                        .search( val ? '^'+val+'$' : '', true, false )
                                        .draw();
                            } );
                    column.data().unique().sort().each( function ( d, j ) {
                        select.append( '<option value="'+d+'">'+d+'</option>' )
                    } );}
            } );
        }
	});
    $(function(){
        /* 自定义过滤函数，判断日期是否时间是否处于2个日期之间 */
        $.fn.dataTable.ext.search.push(
                function (settings, data, dataIndex) {
                    var rx = /^(\d{4})-(0[1-9]|1[012])-(0[1-9]|[12][0-9]|3[01])$/;//日期正则，只判断格式，是否输入正确不加判断
                    var min = $('#datemin').val();
                    var max = $('#datemax').val();
                    var date = new Date(data[1]).getTime();//日期列，Date对象参数可以为----/--/--格式，其他格式需要自己转为此种格式，获取时间戳
                    if (rx.test(min) && rx.test(max)) {
                        min = new Date(min).getTime();
                        max = new Date(max).getTime();
                        return (date >= min && date <= max) || (date >= max && date <= min)//先后时间填写反，如果按照字段说明，那么去掉这个判断
                    }
                    return true;
                }
        );
    })




/*用户-添加*/
function member_add(title,url,w,h){
	layer_show(title,url,w,h);
}

/*用户-编辑*/
function member_edit(title,url,id,w,h){
	layer_show(title,url+id,w,h);
}

/*用户-删除*/
function member_del(obj,id){
	layer.confirm('确认要删除吗？',function(index){
		$.ajax({
			type: 'POST',
			url: '/order/del/id/'+id,
			dataType: 'json',
			success: function(data){
				$(obj).parents("tr").remove();
				layer.msg('已删除!',{icon:1,time:1000});
			},
			error:function(data) {
				console.log(data.msg);
			}
		});		
	});
}
/*批量删除*/
function datadel(){
    var id=[];
    var i=0;
    $(".id:checked").each(function(){
        id[i] =$(this).val();
        i++
    });
    if(id==false){
        layer.msg('没有选择删除项!',{icon:1,time:1000});
        return false;
    }
    layer.confirm('确认批量删除吗？',function(index){
        $.ajax({
            type: 'post',
            url: '/order/batch_del',
            data: {id:id},
            success: function(data){
                for(var i in data){
                    for(var j in data[i]){
                        var id=data[i][j];
                        $(".id").each(function(){
                            if($(this).val()==id){
                                $(this).parents("tr").remove();
                            }
                        })
                    };
                }
                layer.msg('已删除!',{icon:1,time:1000});
            },
            error:function(data) {
                layer.msg('删除失败!',{icon:1,time:1000});
                console.log(data.msg);
            }
        });
    });
}

</script>
<script type="text/javascript">
    $(document).ready(function () {
        var table = $('.table-sort').DataTable();
        //给2个输入框添加blur事件调用draw方法执行自定义过滤函数
        $('#datemin, #datemax').blur(function () {
            table.draw();
        });
    });
</script>
<script type="text/javascript" src="__PUBLIC__/js/excel.js"></script>
</body>
</html>